<!DOCTYPE html>
<html>
<head>
    <title>WebView JS Demo</title>
    <script>
        // 被原生调用的 JS 函数
        function pageIsReady() {
            document.getElementById('status').innerText = 'Page is ready and native bridge is established!';
        }

        // 调用原生的 JS 函数
        function callNativeToast() {
            if (window.CallAndroidInterface) {
                window.CallAndroidInterface.showToast('Hello from WebView!');
            } else {
                alert('CallAndroidInterface interface not found');
            }
        }

        function getModelFromNative() {
            if (window.CallAndroidInterface) {
                const model = window.CallAndroidInterface.getDeviceModel();
                document.getElementById('model').innerText = model;
            }else {
                alert('CallAndroidInterface interface not found');
            }
        }

         function checkAppVersion() {
            if (window.CallAndroidInterface) {
                window.CallAndroidInterface.checkAppVersion();
            } else {
                alert('CallAndroidInterface interface not found');
            }
        }

         function jsGetCardInfo() {
            if (window.CallAndroidInterface) {
                const info = window.CallAndroidInterface.jsGetCardInfo();
                 document.getElementById('model').innerText = info;
            } else {
                alert('CallAndroidInterface interface not found');
            }
        }

        function jsCloseDevices() {
            if (window.CallAndroidInterface) {
                window.CallAndroidInterface.jsCloseDevices();
            } else {
                alert('CallAndroidInterface interface not found');
            }
        }
    </script>
</head>
<body>
<h1>WebView JS Interaction Demo</h1>
<p id="status">Loading...</p>
<!--<button onclick="callNativeToast()">Show Native Toast</button>-->
<br><br>
<button onclick="checkAppVersion()">检查更新</button>
<br><br>
<button onclick="jsGetCardInfo()">读身份证</button>
<button onclick="jsCloseDevices()">关闭身份证读取</button>
<br><br>
<!--<button onclick="getModelFromNative()">Get Device Model</button>-->
<p>info: <span id="model"></span></p>
</body>
</html>